package cn.edu.hqu.cst.android.ls.media;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.MediaController;
import android.widget.VideoView;

import java.io.File;

public class VideoPlay extends AppCompatActivity {
    VideoView videoView;
    Button button;
    EditText url;
    MediaController mController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_play);

        //获取界面上的VideoView组件
        videoView = (VideoView) findViewById(R.id.video);
        //获取视频路径
        url = (EditText) findViewById(R.id.search);
        //获取播放按钮
        button = (Button) findViewById(R.id.play);
        //创建MediaController对象
        mController = new MediaController(this);
        //url.setText(VideoSearch());
        File video = new File("/mnt/sdcard/movie.mp4");
        if (video.exists()) {
            videoView.setVideoPath(video.getAbsolutePath());
            videoView.setMediaController(mController);
            mController.setMediaPlayer(videoView);
            videoView.requestFocus();


        }
    }
}
